/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tamnhat.report.entity;

import com.tamnhat.entity.Category;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import telsoft.admin.util.AppServer;
import telsoft.sql.Database;

/**
 *
 * @author Administrator
 */
public class SYSTEM_LOG implements Serializable{
    private String log_id;
    private String log_date;
    private String tag;
    private String log;

    public SYSTEM_LOG() {
    }

    public SYSTEM_LOG(String log_id, String log_date, String tag, String log) {
        this.log_id = log_id;
        this.log_date = log_date;
        this.tag = tag;
        this.log = log;
    }

    public String getLog_id() {
        return log_id;
    }

    public void setLog_id(String log_id) {
        this.log_id = log_id;
    }

    public String getLog_date() {
        return log_date;
    }

    public void setLog_date(String log_date) {
        this.log_date = log_date;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public String getLog() {
        return log;
    }

    public void setLog(String log) {
        this.log = log;
    }
    
    public static ArrayList<SYSTEM_LOG> getAll(String condition) throws Exception{
        ArrayList<SYSTEM_LOG> list = new ArrayList<SYSTEM_LOG>();
        Connection cn = null;
        Statement st = null;
        ResultSet rs = null;
        String strSQL = "select log_id,to_char(log_date,'dd-mm-yyyy') ngay,tag,log from system_log"
                + " "+condition                
                + " order by log_id,log_date";
        try {
            cn = AppServer.getConnection();
            st = cn.createStatement();
            rs = st.executeQuery(strSQL);
            while (rs.next()) {
                SYSTEM_LOG sl = new SYSTEM_LOG();
                sl.setLog_id(rs.getString(1));
                sl.setLog_date(rs.getString(2));
                sl.setTag(rs.getString(3));
                sl.setLog(rs.getString(4));
                list.add(sl);
            }
            return list;
        } finally {
            Database.closeObject(rs);
            Database.closeObject(st);
            Database.closeObject(cn);
        }
    }
}
